package uz.rt.Anastruct;

import uz.rt.utils.Itemizable;

import java.util.ArrayList;

public class Anastruct implements Comparable<Anastruct>, Itemizable<Integer, Contour>
{
    private ArrayList<Contour> contours = null;

    public Anastruct()
    {
        contours = new ArrayList<Contour>();
    }

    public int compareTo(Anastruct o)
    {
        if (size() != o.size()) return Integer.compare(size(), o.size());
        for (int i = 0; i < size(); i++)
            if (contours.get(i) != o.contours.get(i)) return contours.get(i).compareTo(o.contours.get(i));
        return 0;
    }

    public void add(Contour item)
    {
        contours.add(item);
    }

    public void edit(Integer idx, Contour item)
    {
        contours.set(idx, item);
    }

    public void removeByKey(Integer idx)
    {
        contours.remove(idx.intValue());
    }

    public void removeValue(Contour item)
    {
        contours.remove(item);
    }

    public int size()
    {
        return contours.size();
    }
}
